package com.lgs.xlist.example;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;


import com.lgs.common.widgets.xlist.BaseListAdapter;
import com.lgs.common.widgets.xlist.BaseListItem;

public class BookListItem<T> extends BaseListItem<T> {
    Book book = null;

    @SuppressLint("InflateParams")
    public BookListItem(Context context, int layout, ViewGroup parent) {
        super(context, layout, parent);
    }

    public void  setListItem(int position, T item, BaseListAdapter.IOnClickItemListener<T> onClickListener) {
        super.setListItem(position, item, onClickListener);

        book = (Book) item;

        TextView tvName = itemView.findViewById(R.id.list_item_name);
        tvName.setText(book.getName());

        TextView tvStatus = itemView.findViewById(R.id.list_item_status);
        tvStatus.setText("开始阅读");

        itemView.setOnClickListener((v -> onClickListener.clickItem(1,item)));//整条单击
        itemView.setOnLongClickListener(v -> onClickListener.clickItem(2,item));//整条长按
        tvName.setOnClickListener((v -> onClickListener.clickItem(3,item)));//子项点击
        tvStatus.setOnClickListener((v -> onClickListener.clickItem(4,item)));//子项点击
    }
}
